@import '../../style/checkbox-common';
@import '../../style/noop-animation';

// Padding inside of a pseudo checkbox.
$_mat-pseudo-checkbox-padding: $mat-checkbox-border-width * 2;

// Size of the checkmark in a pseudo checkbox.
$_mat-pseudo-checkmark-size: $mat-checkbox-size - (2 * $_mat-pseudo-checkbox-padding);


.mat-pseudo-checkbox {
  width: $mat-checkbox-size;
  height: $mat-checkbox-size;
  border: $mat-checkbox-border-width solid;
  border-radius: 2px;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
  position: relative;
  flex-shrink: 0;
  transition:
      border-color $mat-checkbox-transition-duration $mat-linear-out-slow-in-timing-function,
      background-color $mat-checkbox-transition-duration $mat-linear-out-slow-in-timing-function;

  // Used to render the checkmark/mixedmark inside of the box.
  &::after {
    position: absolute;
    opacity: 0;
    content: '';
    border-bottom: $mat-checkbox-border-width solid currentColor;
    transition: opacity $mat-checkbox-transition-duration $mat-linear-out-slow-in-timing-function;
  }

  &.mat-pseudo-checkbox-checked, &.mat-pseudo-checkbox-indeterminate {
    border-color: transparent;
  }

  @include _noop-animation {
    &::after {
      transition: none;
    }
  }
}

.mat-pseudo-checkbox-disabled {
  cursor: default;
}

.mat-pseudo-checkbox-indeterminate::after {
  top: ($mat-checkbox-size - $mat-checkbox-border-width) / 2 - $mat-checkbox-border-width;
  left: 0;
  width: $mat-checkbox-size - ($mat-checkbox-border-width * 2);
  opacity: 1;
}

.mat-pseudo-checkbox-checked::after {
  top: ($mat-checkbox-size / 2) - ($_mat-pseudo-checkmark-size / 4) -
      ($mat-checkbox-size / 10) - $mat-checkbox-border-width;
  left: $_mat-pseudo-checkbox-padding - $mat-checkbox-border-width * 1.5;
  width: $_mat-pseudo-checkmark-size;
  height: ($_mat-pseudo-checkmark-size - $mat-checkbox-border-width) / 2;
  border-left: $mat-checkbox-border-width solid currentColor;
  transform: rotate(-45deg);
  opacity: 1;
}
